const path = require("path")
const mockserver = require("mockserver-node");
module.exports = {
    vueCompilerOptions: {
        isCustomElement: tag => tag === 'piechart'
    },
    // 给导入的地址起别名，避免出现大量的嵌套引入
    alias: {
        // 路径映射必须以 / 开头和结尾
        "/comp/": path.resolve(__dirname, "src/components")
    },
    // 使用代理
    proxy: {
        '/api': {
            target: 'http://jsonplaceholder.typicode.com',
            changeOrigin: true,
            rewrite: path => path.replace(/^\/api/, '')
        }
    },
    plugins: [
        // createMockServer({
        //     // close support .ts file
        //     supportTs: false,
        // }),
        mockserver.start_mockserver({
            supportTs: false,
        })
    ],
    configureServer: function ({
        app
    }) {
        app.use(async (ctx, next) => {
            if (ctx.path == '/api/')
                ctx.body = {
                    msg: '1231231'
                }
            await next()
        })
    }

}